import Vue from 'vue'
import Router from 'vue-router'
import config from '@/micros/config'

Vue.use(Router)

// 判断环境是否是微应用打开
let microPath = ''
if (window.__POWERED_BY_QIANKUN__) {
  microPath = config.microPath
}

const router = new Router({
  routes: [
    {
      path: microPath + '/',
      name: 'index',
      component: () => import('@/views/index'),
      redirect: () => {
        return microPath + '/home'
      },
      children: [
        // 首页
        {
          path: 'home',
          name: 'home',
          component: () => import('@/views/index/index')
        }
      ]
    },
    {
      path: microPath + '/chat/index',
      name: 'chat',
      component: () => import('@/views/chat/index')
    }
  ]
})

export default router
